package com.market.product.server.service.impl;

import java.math.BigDecimal;
import java.util.List;

import com.market.common.core.domain.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.market.product.server.mapper.ProductSkuInfoMapper;
import com.market.product.common.domain.ProductSkuInfo;
import com.market.product.server.service.IProductSkuInfoService;

/**
 * 商品SKUService业务层处理
 *
 * @author market
 * @date 2024-02-27
 */
@Service
public class ProductSkuInfoServiceImpl implements IProductSkuInfoService
{
    @Autowired
    private ProductSkuInfoMapper productSkuInfoMapper;

    /**
     * 查询商品SKU
     *
     * @param id 商品SKU主键
     * @return 商品SKU
     */
    @Override
    public ProductSkuInfo selectProductSkuInfoById(Long id)
    {
        return productSkuInfoMapper.selectProductSkuInfoById(id);
    }

    /**
     * 查询商品SKU列表
     *
     * @param productSkuInfo 商品SKU
     * @return 商品SKU
     */
    @Override
    public List<ProductSkuInfo> selectProductSkuInfoList(ProductSkuInfo productSkuInfo)
    {
        return productSkuInfoMapper.selectProductSkuInfoList(productSkuInfo);
    }

    /**
     * 新增商品SKU
     *
     * @param productSkuInfo 商品SKU
     * @return 结果
     */
    @Override
    public int insertProductSkuInfo(ProductSkuInfo productSkuInfo)
    {
        return productSkuInfoMapper.insertProductSkuInfo(productSkuInfo);
    }

    /**
     * 修改商品SKU
     *
     * @param productSkuInfo 商品SKU
     * @return 结果
     */
    @Override
    public int updateProductSkuInfo(ProductSkuInfo productSkuInfo)
    {
        return productSkuInfoMapper.updateProductSkuInfo(productSkuInfo);
    }

    /**
     * 批量删除商品SKU
     *
     * @param ids 需要删除的商品SKU主键
     * @return 结果
     */
    @Override
    public int deleteProductSkuInfoByIds(Long[] ids)
    {
        return productSkuInfoMapper.deleteProductSkuInfoByIds(ids);
    }

    /**
     * 删除商品SKU信息
     *
     * @param id 商品SKU主键
     * @return 结果
     */
    @Override
    public int deleteProductSkuInfoById(Long id)
    {
        return productSkuInfoMapper.deleteProductSkuInfoById(id);
    }

    @Override
    public Result updateProductInventory(Integer productId, Integer stock) {
        return productSkuInfoMapper.updateProductInventory(productId,stock);
    }


    @Override
    public ProductSkuInfo queryPriceBySkuId(Long id) {

        return productSkuInfoMapper.queryPriceBySkuId(id);
    }
}
